ComboPoints = inherit(Singleton)
ComboPoints.events = {}

function ComboPoints:constructor()
	self.m_Frame = CreateFrame("Frame",nil)

	self.m_CombatFrames = {}
	
	self:load()
end

function ComboPoints:load()
	for i = 1, MAXCOMBOPOINTS, 1 do
		self.m_CombatFrames[#self.m_CombatFrames+1] = self:createComboFrame(540+i*50)
	end
	self.m_Frame:SetScript("onUpdate",bind(ComboPoints.onUpdate,self));
end

function ComboPoints:onUpdate()
	for i =1, MAXCOMBOPOINTS, 1 do
		if GetComboPoints("player") >= i then
			self.m_CombatFrames[i]:Show()
		else
			self.m_CombatFrames[i]:Hide()
		end
	end
end

function ComboPoints:createComboFrame(x)
	local tempFrame = CreateFrame("Frame",nil,UIPARENT)
	tempFrame:SetWidth(24)
	tempFrame:SetHeight(24)
	tempFrame:SetPoint("LEFT",x,50)
	tempFrame:SetBackdrop(
		{
			edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
			edgeSize = 8,
		}
	)
	
	local texture = tempFrame:CreateTexture(nil,"BACKGROUND")
	texture:SetTexture("Interface\\Glues\\CharacterCreate\\UI-CharacterCreate-Classes")
	texture:SetTexCoord(UnitPortraitCoord("player"))
	texture:SetAllPoints(tempFrame)
	tempFrame.texture = texture
	
	tempFrame:Hide()
	
	return tempFrame
end